<?php TPL::output('admin/global/header.tpl.htm'); ?>

<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->

<!-- main -->
<div id="main-content">
	<div class="clear"></div>
	<div class="content-box">
		<div class="content-box-header">
			<h3>任务管理</h3>
			<ul class="content-box-tabs">
				<li><a href="#tab1" class="default-tab current">任务列表</a></li>
				<li><a href="#tab2" class="">新建任务</a></li>
			</ul>
			<div class="clear"></div>
		</div>
		<div class="content-box-content">
			<div class="tab-content default-tab" id="tab1">				
				<?php if ($this->tasks_list) { ?>
				<table class="list">
					<thead>
						<tr>
							<th width="50%">任务名称</th>
							<th>用户数量</th>
							<th>发出数量</th>
							<th>阅读数</th>
							<th>建立时间</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody style="border-bottom: 1px solid #ddd;">
						<?php foreach ($this->tasks_list AS $key => $val) { ?>
						<tr>
							<td><?php echo $val['title']; ?></td>
							<td><?php echo $val['users']; ?></td>
							<td><?php echo $val['sent']; ?></td>
							<td><?php echo $val['views']; ?></td>
							<td><?php echo date_friendly($val['time']); ?></a>
							<td><a href="account/edm/mail/<?php echo $val['id']; ?>" target="_blank">邮件内容</a> | <a href="admin/edm/export_active_users/<?php echo $val['id']; ?>">导出活跃用户</a> | <a href="admin/edm/remove_task/<?php echo $val['id']; ?>" onclick="if (confirm('确认删除这个任务?')) { window.location = this.href; } return false;">删除</a></td>
						</tr>
						<?php } ?>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="6">
								<div class="pagination"><?php echo $this->pagination; ?></div>
								<div class="clear"></div>
							</td>
						</tr>
					</tfoot>
				</table>
				<?php } ?>
			</div>
			
			<div class="tab-content" id="tab2" style="display:none;">
				<form action="admin/edm/add_task/" method="post">
				
				<fieldset>
				<p>
					<label>任务标题</label>
						<input class="text-input medium-input" type="text" name="title" />
				</p>
				
				<p>
					<label>邮件标题</label>
						<input class="text-input medium-input" type="text" name="subject" />
				</p>
				
				<p>
					<label>发件人名称</label>
						<input class="text-input medium-input" type="text" name="from_name" value="<?php echo get_setting('site_name'); ?>" />
				</p>
				
				<p>
					<label>用户群组</label>              
					<select name="usergroup_id" class="small-input">
						<option value="0"> - 请选择 - </option>
						<?php foreach ($this->usergroups AS $key => $item) { ?>
						<option value="<?php echo $item['id']; ?>"<?php if ($_GET['usergroup_id'] == $item['id']) { ?> selected="selected"<?php } ?>><?php echo $item['title']; ?></option>
						<?php } ?>
					</select> 
				</p>
				
				<p>
					<label>邮件内容</label>
					<small>请直接粘帖 HTML 代码</small><br />
					<textarea class="text-input textarea" name="message" cols="79" rows="15"></textarea>
				</p>
				
				<p>
					<input class="button" type="submit" value="创建" />
				</p>
					
				</fieldset>
				
				<div class="clear"></div><!-- End .clear -->
				
			</form>
				
			</div>
			
		</div>
		<div class="clear"></div>
	</div>

<!-- footer -->
<?php TPL::output('admin/global/footer.tpl.htm'); ?>
<!-- footer -->

</div>
<!-- main -->

</div>

</body>
</html>